using System.Web.UI;

namespace BilSimser.SharePoint.Common.Controls
{
	public class OWSRichTextField : OWSBase
	{
		#region construction

		/// <summary>
		/// default constructor
		/// </summary>
		public OWSRichTextField()
		{
		}

		#endregion

		#region public properties

		/// <summary>
		/// Gets or set the number of lines for the richtext control. 
		/// </summary>
		public int NumLines
		{
			get
			{
				if (ViewState["NumLines"] == null)
					NumLines = 5;
				return (int) ViewState["NumLines"];
			}
			set { ViewState["NumLines"] = value; }
		}

		#endregion

		#region overridden methods

		protected override void Render (HtmlTextWriter wtr)
		{
			wtr.Write(
				"<SCRIPT>" +
					"fld = new RichTextField(frm, \"{0}\", \"{1}\", \"{2}\");" +
					"fld.fAllowHyperlink = false; " +
					"fld.WebLocale = \"1033\"; " +
					"fld.stNumLines = \"{3}\"; " +
					"fld.fRequired = {4};" +
					"fld.IMEMode = \"\"; " +
					"fld.BuildUI();" +
					"</SCRIPT>",
				UniqueID,
				Display,
				JavaScriptValue,
				NumLines,
				Required.ToString().ToLower()
				);
		}

		#endregion
	}
}